package com.kupurui.asteacher.http;

import android.util.Log;

import com.android.frame.http.HttpListener;
import com.android.frame.http.HttpUtils;
import com.android.frame.http.RequestParams;
import com.facebook.imagepipeline.producers.AddImageTransformMetaDataProducer;
import com.kupurui.asteacher.config.AppConfig;

import java.io.File;
import java.util.List;
import java.util.regex.Pattern;

/**
 * Created by Administrator on 2017/8/18.
 */

public class Teacher {

    private String module = this.getClass().getSimpleName();

    /**
     * 版本更新
     * @param version
     * @param listener
     * @param what
     */
    public void banben(String version,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("",version);
        params.addParam("type","2");
        new HttpUtils().doCall(AppConfig.BASE_URL+"banben/index",params,listener,what);
    }

    /**
     * 登录
     * @param user
     * @param password
     * @param listener
     * @param what
     */
    public void login_2(String user, String password, HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("user",user);
        params.addParam("password",password);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/login_2",params,listener,what);
    }

    /**
     * 忘记密码
     * @param tel
     * @param password
     * @param repassword
     * @param listener
     * @param what
     */
    public void forgetPwd(String tel,String password,String repassword,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("type","1");
        params.addParam("tel",tel);
        params.addParam("password",password);
        params.addParam("repassword",repassword);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/forgetPwd",params,listener,what);
    }

    /**
     * 首页
     * @param id
     * @param listener
     * @param what
     */
    public void xueshengIndex(String id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/xueshengIndex",params,listener,what);
    }

    /**
     * 学生绑定审核
     * @param id
     * @param listener
     * @param what
     */
    public void apply(String id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/apply",params,listener,what);
    }

    /**
     * 审核
     * @param id
     * @param status 2通过 3不通过
     * @param listener
     * @param what
     */
    public void shenhe(String id,String status,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        params.addParam("status",status);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/shenhe",params,listener,what);
    }

    /**
     * 班级详情-学生列表
     * @param class_id
     * @param listener
     * @param what
     */
    public void studentList(String class_id,String sou,String page,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("class_id",class_id);
        params.addParam("sou",sou);
        params.addParam("page",page);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/studentList",params,listener,what);
    }

    /**
     * 学生详情
     * @param id
     * @param student_id
     * @param listener
     * @param what
     */
    public void studentDetail(String id,String student_id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        params.addParam("student_id",student_id);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/studentDetail",params,listener,what);
    }

    /**
     * 学生错题本
     * @param sid
     * @param time
     * @param type
     * @param q_type
     * @param chapter_id
     * @param listener
     * @param what
     */
    public void mistake_ben(String sid,String time,String type,String q_type,String chapter_id,String page,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("sid",sid);
        params.addParam("time",time);
        params.addParam("type",type);
        params.addParam("q_type",q_type);
        params.addParam("chapter_id",chapter_id);
        params.addParam("page",page);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/mistake_ben",params,listener,what);
    }

    /**
     * 章节筛选
     * @param sid
     * @param listener
     * @param what
     */
    public void choose_chap(String sid,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("sid",sid);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/choose_chap",params,listener,what);
    }

    /**
     * 学生作业完成情况
     * @param sid
     * @param listener
     * @param what
     */
    public void work_degree(String sid,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("sid",sid);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/work_degree",params,listener,what);
    }

    /**
     * 学生在线考试情况
     * @param sid
     * @param listener
     * @param what
     */
    public void online_degree(String sid,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("sid",sid);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/online_degree",params,listener,what);
    }

    /**
     * 个人中心
     * @param id
     * @param listener
     * @param what
     */
    public void center(String id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/center",params,listener,what);
    }

    /**
     * 修改头像
     * @param id
     * @param img
     * @param listener
     * @param what
     */
    public void changeImg(String id, File img, HttpListener listener, int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        params.addParam("img",img);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/changeImg",params,listener,what);
    }

    /**
     * 更换手机号
     * @param phone
     * @param id
     * @param listener
     * @param what
     */
    public void changePhone(String phone,String id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("phone",phone);
        params.addParam("id",id);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/changePhone",params,listener,what);
    }

    /**
     * 修改登录密码
     * @param id
     * @param old_pwd
     * @param new_pwd
     * @param que_pwd
     * @param listener
     * @param what
     */
    public void changePwd(String id,String old_pwd,String new_pwd,String que_pwd,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        params.addParam("old_pwd",old_pwd);
        params.addParam("new_pwd",new_pwd);
        params.addParam("que_pwd",que_pwd);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/changePwd",params,listener,what);
    }

    /**
     * 意见反馈
     * @param sid
     * @param content
     * @param contact
     * @param listener
     * @param what
     */
    public void suggest(String sid,String content,String contact,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("sid",sid);
        params.addParam("content",content);
        params.addParam("contact",contact);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/suggest",params,listener,what);
    }

    /**
     * 修改姓名
     * @param id
     * @param name
     * @param listener
     * @param what
     */
    public void changeName(String id,String name,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        params.addParam("name",name);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/changeName",params,listener,what);
    }

    /**
     * 选择年级科目
     * @param listener
     * @param what
     */
    public void chooseGrade(HttpListener listener,int what){
        RequestParams params = new RequestParams();
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/chooseGrade",params,listener,what);
    }

    /**
     * 布置作业
     * @param id
     * @param listener
     * @param what
     */
    public void homework(String id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/homework",params,listener,what);
    }

    /**
     * 选择章节
     * @param id
     * @param listener
     * @param what
     */
    public void chooseChapter(String id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/chooseChapter",params,listener,what);
    }

    /**
     * 选择题目
     * @param type 类型，1：章节；2：专题
     * @param id type为1就是章节ID，为2就是专题ID
     * @param listener
     * @param what
     */
    public void chooseQuestion(String type,String id,String page,String tid ,String types ,String star,String already
            ,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("type",type);
        params.addParam("id",id);
        params.addParam("page",page);
        params.addParam("tid",tid);
        params.addParam("types",types);
        params.addParam("star",star);
        params.addParam("already",already);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/chooseQuestion",params,listener,what);
    }

    /**
     * 选择题目搜索
     * @param search
     * @param page
     * @param listener
     * @param what
     */
    public void fuzzy_search(String search ,String page,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("search",search);
        params.addParam("page",page);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/fuzzy_search",params,listener,what);
    }

    /**
     * 选择题型
     * @param listener
     * @param what
     */
    public void choose_types(HttpListener listener,int what){
        RequestParams params = new RequestParams();
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/choose_types",params,listener,what);
    }

    /**
     * 选择难度
     * @param listener
     * @param what
     */
    public void choose_stars(HttpListener listener,int what){
        RequestParams params = new RequestParams();
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/choose_stars",params,listener,what);
    }

    /**
     * 未做过
     * @param listener
     * @param what
     */
    public void choose_already(HttpListener listener,int what){
        RequestParams params = new RequestParams();
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/choose_already",params,listener,what);
    }

    /**
     * 我的题库
     * @param id
     * @param page
     * @param listener
     * @param what
     */
    public void singleTiku(String id,String page,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        params.addParam("page",page);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/singleTiku",params,listener,what);
    }

    /**
     * 作业预览
     * @param id
     * @param listener
     * @param what
     */
    public void zuoye_yulan(List<String> id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        for (int i =0;i<id.size();i++){
            params.addParam("id["+i+"]",id.get(i));
        }
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/zuoye_yulan",params,listener,what);
    }

    /**
     * 发布作业获取老师下面的班级
     * @param id
     * @param listener
     * @param what
     */
    public void zuoye(String id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/zuoye",params,listener,what);
    }

    /**
     * 发布作业
     * @param teacher_id
     * @param title
     * @param issue_time
     * @param cut_time
     * @param id
     * @param question_id
     * @param listener
     * @param what
     */
    public void publish(String teacher_id, String title, String issue_time, String cut_time, List<String> id,List<String> question_id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("teacher_id",teacher_id);
        params.addParam("title",title);
        params.addParam("issue_time",issue_time);
        params.addParam("cut_time",cut_time);
        for (int i = 0;i<id.size();i++){
            params.addParam("id["+i+"]",id.get(i));
        }
        for (int i = 0;i<question_id.size();i++){
            params.addParam("question_id["+i+"]",question_id.get(i));
        }
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/publish",params,listener,what);
    }

    /**
     * 作业
     * @param id
     * @param listener
     * @param what
     */
    public void assignment(String id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/assignment",params,listener,what);
    }

    /**
     * 作业概览
     * @param id
     * @param class_id
     * @param listener
     * @param what
     */
    public void workDetail(String id,String class_id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        params.addParam("class_id",class_id);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/workDetail",params,listener,what);
    }

    /**
     * 全部作业
     * @param id
     * @param teacher_id
     * @param listener
     * @param what
     */
    public void totalWork(String id,String teacher_id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        params.addParam("teacher_id",teacher_id);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/totalWork",params,listener,what);
    }

    /**
     * 作业提交详情
     * @param id
     * @param class_id
     * @param listener
     * @param what
     */
    public void tijiaoDetail(String id,String class_id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        params.addParam("class_id",class_id);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/tijiaoDetail",params,listener,what);
    }

    /**
     * 催作业
     */
    public void cui_work(String tid,String sid,String work_id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("tid",tid);
        params.addParam("sid",sid);
        params.addParam("work_id",work_id);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/cui_work",params,listener,what);
    }

    /**
     * 个人答题结果
     * @param id
     * @param st_id
     * @param listener
     * @param what
     */
    public void userAnswer(String id,String st_id,String class_id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        params.addParam("st_id",st_id);
        params.addParam("class_id",class_id);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/userAnswer",params,listener,what);
    }

    /**
     * 填写评语
     * @param id
     * @param sid
     * @param content
     * @param listener
     * @param what
     */
    public void comment(String id,String sid,String content,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        params.addParam("sid",sid);
        params.addParam("content",content);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/comment",params,listener,what);
    }

    /**
     * 作业解析
     * @param id
     * @param sid
     * @param listener
     * @param what
     */
    public void zuoye_jiexi(String id,String sid,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        params.addParam("sid",sid);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/zuoye_jiexi",params,listener,what);
    }

    /**
     * 需要批改的题目详情
     * @param id
     * @param class_id
     * @param listener
     * @param what
     */
    public void question_detail(String id,String class_id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        params.addParam("class_id",class_id);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/question_detail",params,listener,what);
    }

    /**
     * 批改作业学生提交的答案
     * @param id
     * @param q_id
     * @param cl_id
     * @param listener
     * @param what
     */
    public void pigaiYe(String id,String q_id,String cl_id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        params.addParam("q_id",q_id);
        params.addParam("cl_id",cl_id);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/pigaiYe",params,listener,what);
    }

    /**
     * 批改
     * @param id
     * @param status
     * @param listener
     * @param what
     */
    public void correct(String id,String status,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        params.addParam("status",status);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/correct",params,listener,what);
    }

    /**
     * 单个题目详情
     * @param q_id
     * @param listener
     * @param what
     */
    public void questionDetail(String q_id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("q_id",q_id);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/questionDetail",params,listener,what);
    }

    /**
     * 某道题的批改情况
     * @param id
     * @param q_id
     * @param listener
     * @param what
     */
    public void singleDetail(String id,String q_id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        params.addParam("q_id",q_id);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/singleDetail",params,listener,what);
    }

    /**
     * 作业预发布
     * @param id
     * @param q_id
     * @param listener
     * @param what
     */
    public void zuoye_info(String id,List<String> q_id,String work_id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        for (int i = 0;i<q_id.size();i++){
            params.addParam("q_id["+i+"]",q_id.get(i));
        }
        params.addParam("work_id",work_id);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/zuoye_info",params,listener,what);
    }

    /**
     * 预发布保存
     * @param teacher_id
     * @param title
     * @param issue_time
     * @param cut_time
     * @param listener
     * @param what
     */
    public void zuoye_fabu(String teacher_id,String title,String issue_time,String cut_time,List<String> id,List<String> question_id,String work_id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("teacher_id",teacher_id);
        params.addParam("title",title);
        params.addParam("issue_time",issue_time);
        params.addParam("cut_time",cut_time);
        for (int i = 0;i<id.size();i++){
            params.addParam("id["+i+"]",id.get(i));
        }
        for (int i = 0; i <question_id.size();i++){
            params.addParam("question_id["+i+"]",question_id.get(i));
        }
        params.addParam("work_id",work_id);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/zuoye_fabu",params,listener,what);
    }

    /**
     * 修改 作业
     * @param id
     * @param listener
     * @param what
     */
    public void assignment22(String id,HttpListener listener,int what){
        RequestParams params = new RequestParams();
        params.addParam("id",id);
        new HttpUtils().doCall(AppConfig.BASE_URL+module+"/assignment22",params,listener,what);
    }

}
